/*
 * Copyright (c) 2020 hebeiyiliuba.com
 * All rights reserved.
 *
 */
package org.jeecg.modules.api.wlhy.driver;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.constant.enums.ExamineStatusEnum;
import org.jeecg.common.constant.enums.MessageTypeEnum;
import org.jeecg.common.constant.enums.ReportPlatformEnum;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.DictUtil;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.modules.middleware.rabbitmq.gen.EnumGenHandler;
import org.jeecg.modules.middleware.rabbitmq.gen.GenMqUtil;
import org.jeecg.modules.third.digitalseal.service.DigitalSignetService;
import org.jeecg.modules.third.digitalseal.utils.GeneratePDF;
import org.jeecg.modules.third.ecloud.sdk.EclouModel;
import org.jeecg.modules.third.ecloud.sdk.bean.ECloudDomain;
import org.jeecg.modules.third.ecloud.sdk.http.EcloudClient;
import org.jeecg.modules.third.nucarf.GasService;
import org.jeecg.modules.wlhy.company.entity.HyCompany;
import org.jeecg.modules.wlhy.company.entity.HyCompanyConfig;
import org.jeecg.modules.wlhy.company.service.IHyCompanyConfigService;
import org.jeecg.modules.wlhy.company.service.IHyCompanyService;
import org.jeecg.modules.wlhy.customer.entity.HyCustomerCompany;
import org.jeecg.modules.wlhy.customer.entity.HyCustomerConfig;
import org.jeecg.modules.wlhy.customer.service.IHyCustomerCompanyService;
import org.jeecg.modules.wlhy.customer.service.IHyCustomerConfigService;
import org.jeecg.modules.wlhy.enterprise.entity.HyEnterprise;
import org.jeecg.modules.wlhy.enterprise.service.IHyEnterpriseService;
import org.jeecg.modules.wlhy.gas.entity.HyShippingNoteGas;
import org.jeecg.modules.wlhy.gas.service.IHyShippingNoteGasService;
import org.jeecg.modules.wlhy.hyconfig.entity.HyConfig;
import org.jeecg.modules.wlhy.hydriver.entity.HyDriver;
import org.jeecg.modules.wlhy.hydriver.service.IHyDriverService;
import org.jeecg.modules.wlhy.hydriverbank.entity.HyDriverBank;
import org.jeecg.modules.wlhy.hydriverbank.service.IHyDriverBankService;
import org.jeecg.modules.wlhy.hydrivercustomer.service.IHyDriverCustomerService;
import org.jeecg.modules.wlhy.hyevent.event.AppLocationEvent;
import org.jeecg.modules.wlhy.hyevent.event.ShippingNoticeEvent;
import org.jeecg.modules.wlhy.hyvehicle.entity.HyVehicle;
import org.jeecg.modules.wlhy.hyvehicle.service.IHyVehicleService;
import org.jeecg.modules.wlhy.order.entity.HyOrder;
import org.jeecg.modules.wlhy.order.entity.HyOrderPrice;
import org.jeecg.modules.wlhy.order.service.IHyOrderDriverService;
import org.jeecg.modules.wlhy.order.service.IHyOrderPriceService;
import org.jeecg.modules.wlhy.order.service.IHyOrderService;
import org.jeecg.modules.wlhy.order.vo.HyOrderDriverVO;
import org.jeecg.modules.wlhy.order.vo.HyOrderPriceVO;
import org.jeecg.modules.wlhy.report.IReportService;
import org.jeecg.modules.wlhy.report.OrdosReportService;
import org.jeecg.modules.wlhy.report.ReportServiceFactory;
import org.jeecg.modules.wlhy.report.ShippingNoteApiAlct56Service;
import org.jeecg.modules.wlhy.setting.entity.HySetting;
import org.jeecg.modules.wlhy.setting.service.IHySettingService;
import org.jeecg.modules.wlhy.shipping.constant.ShippingStatus;
import org.jeecg.modules.wlhy.shipping.entity.HyShippingNote;
import org.jeecg.modules.wlhy.shipping.entity.HyShippingNotePayDTO;
import org.jeecg.modules.wlhy.shipping.service.IHyShippingNoteService;
import org.jeecg.modules.wlhy.shippingnoteviolation.entity.HyShippingNoteViolation;
import org.jeecg.modules.wlhy.shippingnoteviolation.service.IHyShippingNoteViolationService;
import org.jeecg.modules.wlhy.utils.CodeUtil;
import org.jeecg.modules.wlhy.utils.HyCfgUtil;
import org.jeecg.modules.wlhy.utils.HyConfigUtils;
import org.jeecg.modules.wlhy.utils.UserUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Set;

/**
 * 在这里编写类的功能描述
 *
 * @author duanlikao
 * @created 2020/12/4
 */
@Api(tags = "司机运单")
@RestController
@RequestMapping("/api/wlhy/driver/shipping")
@Slf4j
public class ApiDriverShippingController extends JeecgController<HyDriver, IHyDriverService> {

    private final Logger logger = LoggerFactory.getLogger(ApiDriverShippingController.class);
    @Autowired
    private IHyShippingNoteService hyShippingNoteService;

    @Autowired
    private IHyShippingNoteViolationService shippingNoteViolationService;

    @Autowired
    private IHyDriverService hyDriverService;

    @Autowired
    private IHyOrderService orderService;

    @Autowired
    private IHyVehicleService vehicleService;

    @Autowired
    private DictUtil dictUtil;

    @Autowired
    private IHySettingService settingService;

    @Autowired
    private IHyOrderPriceService hyOrderPriceService;

    @Autowired
    private IHyOrderDriverService hyOrderDriverService;

    @Autowired
    private RedisUtil redisUtil;

    @Autowired
    private IHyCompanyConfigService hyCompanyConfigService;

    @Autowired
    private IHyShippingNoteGasService hyShippingNoteGasService;

    @Autowired
    private IHySettingService hySettingService;

    @Autowired
    private IHyEnterpriseService hyEnterpriseService;

    @Autowired
    private IHyDriverBankService hyDriverBankService;

    @Autowired
    private IHyCompanyService hyCompanyService;

    @Autowired
    private ShippingNoteApiAlct56Service shippingNoteApiAlct56Service;

    private String PATH_SUBFIX;


    @Value(value = "${jeecg.path.upload}")
    private String uploadpath;

    @Autowired
    private DigitalSignetService digitalSignetService;

    @Autowired
    private IHyCustomerConfigService customerConfigService;

    //文件保存地址路径
    private String SAVE_CONTRACT_ADDR = "documents" + File.separator + DateUtils.getDate("yyyyMMdd") + File.separator;

    /*@Value(value = "${APPID}")
    private String APPID;*/

    @Autowired
    private UserUtil userUtil;

    @Autowired
    private GasService gasService;

    @Autowired
    private IHyDriverCustomerService hyDriverCustomerService;

    @Autowired
    private ApplicationEventPublisher applicationEventPublisher;

    @Autowired
    private IHyCustomerCompanyService hyCustomerCompanyService;

    @Autowired
    private GeneratePDF generatePDF;

    @Autowired
    private OrdosReportService ordosReportService;

    @Autowired
    private IHyCompanyConfigService companyConfigService;

    @ApiOperation(value = "运单表-分页列表查询", notes = "运单表-分页列表查询")
    @GetMapping(value = "/list")
    public Result<?> queryPageList(HyShippingNote hyShippingNote,
                                   @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                   @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                   HttpServletRequest req) {
        HyDriver driver = userUtil.getDriver();
        QueryWrapper<HyShippingNote> queryWrapper = QueryGenerator.initQueryWrapper(hyShippingNote, req.getParameterMap());
        queryWrapper.eq("driver_id", driver.getId());

        if (StringUtils.isNotEmpty(hyShippingNote.getKeyword())) {
            queryWrapper.and(
                    qw -> qw.like("send_address_name", hyShippingNote.getKeyword())
                            .or().like("receive_address_name", hyShippingNote.getKeyword())
            );
        }

        Page<HyShippingNote> page = new Page<HyShippingNote>(pageNo, pageSize);
        IPage<HyShippingNote> pageList = hyShippingNoteService.page(page, queryWrapper);
        return Result.OK(pageList);
    }

    @ApiOperation(value = "运单表-分页列表查询", notes = "运单表-分页列表查询")
    @GetMapping(value = "/payList")
    public Result<?> queryPageList(HyShippingNotePayDTO hyShippingNotePayDTO,
                                   @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                   @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                   HttpServletRequest req) {
        HyDriver driver = userUtil.getDriver();
        HyShippingNote hyShippingNote = new HyShippingNote();

        QueryWrapper<HyShippingNote> queryWrapper = QueryGenerator.initQueryWrapper(hyShippingNote, req.getParameterMap());
        queryWrapper.eq("driver_id", driver.getId());

        if (StringUtils.isNotEmpty(hyShippingNotePayDTO.getKeyword())) {
            queryWrapper.and(
                    qw -> qw.like("send_address_name", hyShippingNotePayDTO.getKeyword())
                            .or().like("receive_address_name", hyShippingNotePayDTO.getKeyword())
            );
        }

        if (hyShippingNotePayDTO.getPay()!=null&&!hyShippingNotePayDTO.getPay().equals("")){
            //如果pay等于0则返回未支付状态
            //运单结算状态(0未对账 1申请对账 2对账完成 3待审核 4审核完成 5申请支付 6支付完成  7支付失败 8驳回 9 业务审核 10 业务审核驳回)"
            //未支付判断  shippingPayStatus 不等于6 且不等于7  且 shippingStatus 大于1 小于8
            if (hyShippingNotePayDTO.getPay().equals("0")){
                queryWrapper.gt("shipping_status","1");
                queryWrapper.lt("shipping_status","8");
                queryWrapper.ne("shipping_pay_status","6");
                queryWrapper.ne("shipping_pay_status","7");
                Page<HyShippingNote> page = new Page<HyShippingNote>(pageNo, pageSize);
                IPage<HyShippingNote> pageList = hyShippingNoteService.page(page, queryWrapper);
                return Result.OK(pageList);
            }
            //如果pay等于1则返回已支付状态
            //已支付判断  shippingPayStatus 等于6 或 等于7  且 shippingStatus 大于1 小于8
            if (hyShippingNotePayDTO.getPay().equals("1")){
                queryWrapper.gt("shipping_status","1");
                queryWrapper.lt("shipping_status","8");
                queryWrapper.and(QueryWrapper -> QueryWrapper.eq("shipping_pay_status", "6").or().eq("shipping_pay_status", "7"));
               /* queryWrapper.eq("shipping_pay_status","6");
                queryWrapper.or().eq("shipping_pay_status","7");*/
                Page<HyShippingNote> page = new Page<HyShippingNote>(pageNo, pageSize);
                IPage<HyShippingNote> pageList = hyShippingNoteService.page(page, queryWrapper);


                return Result.OK(pageList);
            }
        }

        Page<HyShippingNote> page = new Page<HyShippingNote>(pageNo, pageSize);
        IPage<HyShippingNote> pageList = hyShippingNoteService.page(page, queryWrapper);
        return Result.OK(pageList);
    }


    @ApiOperation(value = "运单表-获取司机当前正在进行的运单", notes = "运单表-获取司机当前正在进行的运单")
    @GetMapping(value = "/getCurrentShippingNote")
    public Result<?> getCurrentShippingNote(HyShippingNote hyShippingNote,
                                            @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                            @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                            HttpServletRequest req) {
        HyDriver driver = userUtil.getDriver();
        QueryWrapper<HyShippingNote> queryWrapper = QueryGenerator.initQueryWrapper(hyShippingNote, req.getParameterMap());
        queryWrapper.eq("driver_id", driver.getId()).eq("del_flag", 0)
                .in("shipping_status", "1", "2", "3");
        Page<HyShippingNote> page = new Page<HyShippingNote>(pageNo, pageSize);
        IPage<HyShippingNote> pageList = hyShippingNoteService.page(page, queryWrapper);
        return Result.OK(pageList);

    }


    /**
     * 下载合同
     */
    @AutoLog(value = "APP电子签章-下载合同")
    @ApiOperation(value = "APP电子签章-下载合同", notes = "APP电子签章-下载合同")
    @GetMapping(value = "/downContract")
    public Result<?> downContract(@RequestParam(name = "id", required = true) String id) {
        HyShippingNote shippingNote = hyShippingNoteService.getById(id);
        if (shippingNote.getContractOr().equals("0")) {
            return Result.OK(shippingNote.getShippingContract());
        } else {
            PATH_SUBFIX = uploadpath + File.separator;
            String path2 = PATH_SUBFIX + SAVE_CONTRACT_ADDR;
            File fileDir = new File(path2);
            if (!fileDir.exists()) {
                fileDir.mkdirs();//创建目录
            }
            String contractPath = SAVE_CONTRACT_ADDR + "运输协议_" + DateUtils.getDate("yyyyMMddHHmmss") + ".pdf";

            PATH_SUBFIX = uploadpath + File.separator;
            String path = contractPath;
            String filename = PATH_SUBFIX + path;
            HyEnterprise hyEnterprise = hyEnterpriseService.queryTopData();
            //下载合同  等待点击查看时下载合同
            ECloudDomain sx = EcloudClient.downloadCont(shippingNote.getContractNum(), hyEnterprise.getLegalerTel(), filename);
//            logger.info("sx" + JSONObject.toJSONString(sx));
            shippingNote.setShippingContract(contractPath);
            hyShippingNoteService.updateById(shippingNote);
            return Result.OK(path);
        }
    }

    /**
     * 下载合同2
     */
    @AutoLog(value = "APP电子签章-下载合同")
    @ApiOperation(value = "APP电子签章-下载合同", notes = "APP电子签章-下载合同")
    @GetMapping(value = "/downContract2")
    public Result<?> downContract2(@RequestParam(name = "id", required = true) String id) {
        HyShippingNote shippingNote = hyShippingNoteService.getById(id);
        return Result.OK(shippingNote.getShippingContract2());
    }

    /**
     * 下载合同2
     */
    @AutoLog(value = "APP电子签章-下载合同")
    @ApiOperation(value = "APP电子签章-下载合同", notes = "APP电子签章-下载合同")
    @GetMapping(value = "/downContract3")
    public Result<?> downContract3(@RequestParam(name = "id", required = true) String id) {
        HyShippingNote shippingNote = hyShippingNoteService.getById(id);
        HyCustomerCompany customerCompany = hyCustomerCompanyService.getByCustomerId(shippingNote.getCustomerId());
        return Result.OK(customerCompany.getImgContract());
    }


    /**
     * 批量签订合同
     */
    @AutoLog(value = "批量电子签章")
    @ApiOperation(value = "批量电子签章", notes = "批量电子签章")
    @GetMapping(value = "/changeContractBatch")
    public Result<?> changeContractBatch(@RequestParam(name = "ids", required = true) String ids) {

        if (StrUtil.isEmpty(ids)) {
            return Result.error("请选择运单");
        }

        List<String> idList = Arrays.asList(ids.split(","));
        List<HyShippingNote> shippingNoteList = this.hyShippingNoteService.list(new LambdaQueryWrapper<HyShippingNote>().in(HyShippingNote::getId, idList));
        for (HyShippingNote hyShippingNote : shippingNoteList) {
            HyOrder order = orderService.getById(hyShippingNote.getOrderId());
            if (order == null) {
                return Result.error(order.getOrderNum() + ",货源信息异常");
            }
            HyCustomerCompany customerCompany = hyCustomerCompanyService.getByCustomerId(hyShippingNote.getCustomerId());
            if (customerCompany == null) {
                return Result.error(customerCompany.getCompanyId() + ",货主未绑定分公司");
            }
            HyCompany company = hyCompanyService.getById(customerCompany.getCompanyId());
            if (company == null) {
                return Result.error(company.getCompanyName() + ",分公司信息不存在");
            }

            if (StringUtils.isEmpty(company.getElectronicSeal())) {
                return Result.error("请配置分公司电子公章");
            }

            HyDriver driver = hyDriverService.getById(hyShippingNote.getDriverId());
            if (StringUtils.isEmpty(driver.getDriverAutograph())) {
                return Result.error("司机签名图片不能为空");
            }

            if ("0".equals(hyShippingNote.getContractOr())) {
                JSONObject joOrder = dictUtil.parseObjectDict(order);
                if (null != order.getSendDate()) {
                    joOrder.put("sendDate", DateUtils.dateTimeToString(order.getSendDate()));
                }
                if (null != order.getReceiveDate()) {
                    joOrder.put("receiveDate", DateUtils.dateTimeToString(order.getReceiveDate()));
                }

                String contractNum = CodeUtil.createContractNum();
                joOrder.put("contractNum", contractNum);
                Result result = generatePDF.pdfUtil(joOrder,hyShippingNote, driver);
                if (result.isSuccess()) {
                    HyShippingNote shippingNote = new HyShippingNote();
                    shippingNote.setId(hyShippingNote.getId());
                    shippingNote.setShippingContract(result.getResult().toString());
                    shippingNote.setContractNum(contractNum);
                    shippingNote.setContractNum2(contractNum);
                    shippingNote.setContractType("承运人电子合同");
                    shippingNote.setContractStatus("1");
                    shippingNote.setContractOr("0");
                    hyShippingNoteService.updateById(shippingNote);
                } else {
                    return result;
                }
            } else {
                HyConfig config = HyConfigUtils.getConfig();
                if (config == null) {
                    return Result.error("未读取到配置信息");
                }

                if (!config.getYyzContractIzUse()) {
                    return Result.error("未开启易云章配置");
                }
                HyVehicle vehicle = vehicleService.getById(hyShippingNote.getVehicleId());

                hyShippingNote.setShippingContract("");
                hyShippingNoteService.updateById(hyShippingNote);
                EclouModel eclouModel = new EclouModel();
                eclouModel.setHyDriverId(driver.getId());
                eclouModel.setHyEnterpriseId(company.getId());
                eclouModel.setVehicleId(vehicle.getId());
                eclouModel.setShippingNoteId(hyShippingNote.getId());
                //签署易云章合同节点-订阅消息
                //publisherRedisMessageService.publisherRedisMessage(RedisChannelEnum.ECLOUD_SDK,eclouModel);
                //签署易云章合同节点-rabbmq
                //GenMqUtil.sendMsg(EnumGenHandler.YYZ_HANDLER, "", eclouModel);
            }
        }

        return Result.OK();
    }


    /**
     * 重签合同
     */
    @AutoLog(value = "APP电子签章-因为经常有破损等情况会变更运价，然后需要重签合同")
    @ApiOperation(value = "APP电子签章-因为经常有破损等情况会变更运价，然后需要重签合同", notes = "APP电子签章-因为经常有破损等情况会变更运价，然后需要重签合同")
    @GetMapping(value = "/changeContract")
    public Result<?> changeContract(@RequestParam(name = "id", required = true) String id) {

        HyShippingNote hyShippingNote = hyShippingNoteService.getById(id);
        if (hyShippingNote == null) {
            return Result.error("运单信息异常!");
        }
        HyOrder order = orderService.getById(hyShippingNote.getOrderId());
        if (order == null) {
            return Result.error("货源信息异常!");
        }
        HyCustomerCompany customerCompany = hyCustomerCompanyService.getByCustomerId(hyShippingNote.getCustomerId());
        if (customerCompany == null) {
            return Result.error("货主未绑定分公司");
        }
        HyCompany company = hyCompanyService.getById(customerCompany.getCompanyId());
        if (company == null) {
            return Result.error("分公司信息不存在");
        }
        if (StringUtils.isEmpty(company.getElectronicSeal())) {
            return Result.error("请配置分公司电子公章");
        }
        HyDriver driver = hyDriverService.getById(hyShippingNote.getDriverId());

        if (StringUtils.isEmpty(driver.getDriverAutograph())) {
            return Result.error("司机签名图片不能为空");
        }

        if ("0".equals(hyShippingNote.getContractOr())) {
            JSONObject joOrder = dictUtil.parseObjectDict(order);
            if (null != order.getSendDate()) {
                joOrder.put("sendDate", DateUtils.dateTimeToString(order.getSendDate()));
            }
            if (null != order.getReceiveDate()) {
                joOrder.put("receiveDate", DateUtils.dateTimeToString(order.getReceiveDate()));
            }

            String contractNum = CodeUtil.createContractNum();
            joOrder.put("contractNum", contractNum);
            Result result = generatePDF.pdfUtil(joOrder,hyShippingNote, driver);
            if(result.isSuccess()){
                hyShippingNote.setShippingContract(result.getResult().toString());
                hyShippingNote.setContractNum(contractNum);
                hyShippingNote.setContractNum2(contractNum);
                hyShippingNote.setContractType("承运人电子合同");
                hyShippingNote.setContractStatus("1");
                hyShippingNote.setContractOr("0");
                hyShippingNoteService.updateById(hyShippingNote);
            } else {
                return result;
            }
        } else {
            HyConfig config = HyConfigUtils.getConfig();
            if (config == null) {
                return Result.error("未读取到配置信息");
            }

            if (!config.getYyzContractIzUse()) {
                return Result.error("未开启易云章配置");
            }
            HyVehicle vehicle = vehicleService.getById(hyShippingNote.getVehicleId());

            hyShippingNote.setShippingContract("");
            hyShippingNoteService.updateById(hyShippingNote);
            EclouModel eclouModel = new EclouModel();
            eclouModel.setHyDriverId(driver.getId());
            eclouModel.setHyEnterpriseId(company.getId());
            eclouModel.setVehicleId(vehicle.getId());
            eclouModel.setShippingNoteId(hyShippingNote.getId());
            //签署易云章合同节点-订阅消息
            //publisherRedisMessageService.publisherRedisMessage(RedisChannelEnum.ECLOUD_SDK,eclouModel);
            //签署易云章合同节点-rabbmq
            GenMqUtil.sendMsg(EnumGenHandler.YYZ_HANDLER, "", eclouModel);
        }

        return Result.OK();
    }

    @AutoLog(value = "运单表-扫码接单")
    @ApiOperation(value = "运单表-扫码接单", notes = "运单表-扫码接单")
    @PostMapping(value = "/add")
    public Result<?> add(@RequestBody JSONObject jsonObject) {
        HyDriver driver = userUtil.getDriver();
        String orderId = jsonObject.getString("orderId");
        String vehicleId = jsonObject.getString("vehicleId");
        HySetting hySetting = settingService.getByTag("checkValidDriver");
        if (hySetting!=null&&hySetting.getData().equals("1")){
            Result result = hyDriverService.checkValidDriver(driver);
            if (result.getCode() == 500) {
                return Result.error(result.getMessage());
            }
        }



        if (StringUtils.isEmpty(orderId)) {
            return Result.error("请选择所属货源");
        }
        if (StringUtils.isEmpty(vehicleId)) {
            return Result.error("请选择车辆");
        }

        HyOrder order = orderService.getById(orderId);

        String shippingContract = null;

       /* //如果签名图片不等于空直接系统签字
        if (StrUtil.isEmpty(jsonObject.getString("shippingContract")) && driver.getDriverAutograph() != null) {
            JSONObject joOrder = dictUtil.parseObjectDict(order);
            //合同地址
            String contractPath = digitalSignetService.draftShippingContract(joOrder);
            shippingContract = contractPath;
            digitalSignetService.addSignetForShipping(contractPath, driver.getDriverAutograph(), driver.getDriverName());
        } else {
            shippingContract = jsonObject.getString("shippingContract");
        }*/

        if (order == null) {
            return Result.error("请选择所属货源");
        }
        if ("8".equals(order.getOrderStatus())) {
            return Result.error("该货源已完结,不能接单");
        }
        if (!"2".equals(order.getOrderStatus())) {
            return Result.error("该货源未发布,不能接单");
        }
        HyOrderPrice orderPrice = null;
        if ("2".equals(order.getOrderType())) {
            String orderType2 = order.getOrderType2();
            if ("1".equals(orderType2)) {
                //1抢单
                String prefix = "qd:" + order.getId() + "::";
                String key = prefix + driver.getId();
                if (!redisUtil.hasKey(key)) {
                    return Result.error("未找到抢单信息,不能接单");
                }

            } else if ("2".equals(orderType2)) {
                //2竞价
                String id = jsonObject.getString("jjid");
                if (StringUtils.isEmpty(id)) {
                    return Result.error("未找到该竞价信息");
                }
                orderPrice = hyOrderPriceService.getById(id);
                if (orderPrice == null) {
                    return Result.error("未找到该竞价信息");
                }
                if (!StringUtils.equals(driver.getId(), orderPrice.getDriverId())) {
                    return Result.error("未找到该竞价信息");
                }
                if (!StringUtils.equals(orderId, orderPrice.getOrderId())) {
                    return Result.error("未找到货源信息");
                }
                if (!"1".equals(orderPrice.getPriceSt())) {
                    return Result.error("货主尚未同意,不能接单");
                }
            } else {
                return Result.error("该货源信息错误");
            }
        }
        QueryWrapper<HyVehicle> queryWrapperVehicle = new QueryWrapper<>();
        queryWrapperVehicle.eq("id", vehicleId);
        queryWrapperVehicle.eq("examine_status", ExamineStatusEnum.EXAMINE_STATUS_APPROVED.getCode());
        HyVehicle vehicle = vehicleService.getOne(queryWrapperVehicle);
        if (vehicle == null) {
            return Result.error("车辆信息不存在或车辆未通过审核。");
        }
        if (vehicle.getIzUsed().equals("0")){
            return Result.error("您的车辆处于未启用状态，不能接单！请联系管理员");
        }
        String driverBankId = jsonObject.getString("driverBankId");
        if (StringUtils.isNotEmpty(driverBankId)) {
            HyDriverBank driverBank = hyDriverBankService.getById(driverBankId);
            if (driverBank == null) {
                return Result.error("银行卡信息不存在");
            }
            if (!StringUtils.equals(driverBank.getDriverId(), driver.getId())) {
                return Result.error("银行卡信息错误");
            }
        } else {
            HyCustomerConfig customerConfig = customerConfigService.getByCustomerId(order.getCustomerId());
            if (customerConfig != null) {
                if ("1".equals(customerConfig.getIsOrderBank())) {
                    return Result.error("请选择银行卡");
                }
            }
            //查找司机默认银行卡
            HyDriverBank defaultDriverBank = hyDriverBankService.getDefaultDriverBank(driver.getId());
            if (defaultDriverBank != null) {
                driverBankId = defaultDriverBank.getId();
            }
        }
        if (!"2".equals(order.getOrderType())) {
            //司机 货主添加关系表
            hyDriverCustomerService.addDriverCustomer(driver.getId(), order.getCustomerId());
            hyDriverCustomerService.addVehicleCustomer(vehicleId, order.getCustomerId());
        }


        //vehicle_tonnage
        //验证车辆是否司机车辆
//        if(!StringUtils.equals(driver.getId(),vehicle.getDriverId())){
//            return Result.error("车辆信息错误");
//        }

        //运输合同地址
//        String shippingContract = jsonObject.getString("shippingContract");

//        hyShippingNoteService.getByIdForUpdate(id)

        if (HyCfgUtil.isUsed2("driver_order_receiving_limit")) {
            String driverOrderReceivingLimit = HyCfgUtil.getCfgValue("driver_order_receiving_limit");
            if (StringUtils.isNotEmpty(driverOrderReceivingLimit)) {
                String driverFeeSum = hyShippingNoteService.getDriverFeeSum(driver.getId());
                if (StringUtils.isNotEmpty(driverFeeSum)) {
                    Integer d1 = Integer.valueOf(driverOrderReceivingLimit);
                    Integer d2 = Integer.valueOf(driverFeeSum.substring(0, driverFeeSum.indexOf(".")));
                    if (d2 >= d1) {
                        return Result.error("当月累计收入运费超出限制,不允许接单!");
                    }
                }
            }
        }

        String shippingContract2 = jsonObject.getString("shippingContract2");
        Result r = hyShippingNoteService.addByOrder(order, driver, vehicle, orderPrice, shippingContract, shippingContract2, driverBankId);
        return r;
    }

    @AutoLog(value = "运单表-司机接单")
    @ApiOperation(value = "运单表-司机接单", notes = "司机待接单运单接单，选择车辆")
    @PostMapping(value = "/jiedan")
    //@Transactional
    public Result<?> jiedan(@RequestBody JSONObject jsonObject) {
        HyDriver driver = userUtil.getDriver();
        String id = jsonObject.getString("id");
        if (StringUtils.isEmpty(id)) {
            return Result.error("运单id不能为空");
        }
        String vehicleId = jsonObject.getString("vehicleId");
        if (StringUtils.isEmpty(vehicleId)) {
            return Result.error("车辆id不能为空");
        }
        HyShippingNote shippingNote = hyShippingNoteService.getByIdForUpdate(id);
        if (shippingNote == null) {
            return Result.error("运单信息不存在");
        }
        if (!"0".equals(shippingNote.getShippingStatus())) {
            return Result.error("该运单已接单,不能重复操作");
        }
        if (!StringUtils.equals(driver.getId(), shippingNote.getDriverId())) {
            return Result.error("运单信息错误");
        }
        HyVehicle vehicle = vehicleService.getById(vehicleId);
        if (vehicle.getIzUsed().equals("0")){
            return Result.error("您的车辆处于未启用状态，不能接单！请联系管理员");
        }

        String driver_is_examine = hySettingService.getSettingValueByTag2("driver_is_examine");
        //0关闭 1打开
        if ("1".equals(driver_is_examine)) {
            if ("3".equals(driver.getExamineStatus())) {
                return Result.error("因证件信息错误未审核通过，暂不能接单，请及时更正");
            }
        }
        String shippingContract = null;
        HyOrder order = orderService.getById(shippingNote.getOrderId());
        if (order == null) {
            return Result.error("货源信息错误");
        }
        String driverBankId = jsonObject.getString("driverBankId");
        if (StringUtils.isNotEmpty(driverBankId)) {
            HyDriverBank driverBank = hyDriverBankService.getById(driverBankId);
            if (driverBank == null) {
                return Result.error("银行卡信息不存在");
            }
            if (!StringUtils.equals(driverBank.getDriverId(), driver.getId())) {
                return Result.error("银行卡信息错误");
            }
        } else {
            HyCustomerConfig customerConfig = customerConfigService.getByCustomerId(order.getCustomerId());
            if (customerConfig != null) {
                if ("1".equals(customerConfig.getIsOrderBank())) {
                    return Result.error("请选择银行卡");
                }
            }
            //查找司机默认银行卡
            HyDriverBank defaultDriverBank = hyDriverBankService.getDefaultDriverBank(driver.getId());
            if (defaultDriverBank != null) {
                driverBankId = defaultDriverBank.getId();
            }
        }
        shippingNote.setDriverBankId(driverBankId);

        //如果司机签名图片不等于空直接使用之前司机签名图片签字
      /*  if (driver.getDriverAutograph() != null) {
            JSONObject joOrder = dictUtil.parseObjectDict(order);
            if (null != order.getSendDate()) {
                joOrder.put("sendDate", DateUtils.dateTimeToString(order.getSendDate()));
            }
            if (null != order.getReceiveDate()) {
                joOrder.put("receiveDate", DateUtils.dateTimeToString(order.getReceiveDate()));
            }

            String contractNum = CodeUtil.createContractNum();
            joOrder.put("contractNum", contractNum);
            Result result = generatePDF.pdfUtil(joOrder, shippingNote, driver);
            if(result.isSuccess()){
                shippingNote.setShippingContract(result.getResult().toString());
                shippingNote.setContractNum(contractNum);
                shippingNote.setContractNum2(contractNum);
                shippingNote.setContractType("承运人电子合同");
                shippingNote.setContractStatus("1");
                shippingNote.setContractOr("0");
            }else{
                return result;
            }
            //合同地址
//            String contractPath = digitalSignetService.draftShippingContract(joOrder);
            shippingContract = result.getResult().toString();
//            digitalSignetService.addSignetForShipping(contractPath, driver.getDriverAutograph(), driver.getDriverName());
        } else {
            shippingContract = jsonObject.getString("shippingContract");
        }*/
        //运输合同地址
        if (StringUtils.isNotEmpty(shippingContract)) {
            //查询使用合同模板是哪个
            String contractTemplate = "0";
            String contract_template = hySettingService.getSettingValueByTag2("contract_template");
            if (!StringUtils.isEmpty(contract_template)) {
                contractTemplate = contract_template;
            }
            if (contractTemplate.equals("0")) {
                //设置运输协议地址
                shippingNote.setShippingContract(shippingContract);
                String contractNum = CodeUtil.createContractNum();
                shippingNote.setContractNum(contractNum);
                shippingNote.setContractNum2(contractNum);
                shippingNote.setContractType("承运人电子合同");
                shippingNote.setContractStatus("1");
                shippingNote.setContractOr("0");
            }
        }


        return hyShippingNoteService.jiedan(shippingNote, vehicleId);
    }

    @AutoLog(value = "运单表-运单装货")
    @ApiOperation(value = "运单表-装货", notes = "运单表-装货")
    @PostMapping(value = "/loading")
    @Transactional
    public Result<?> loading(@RequestBody JSONObject jsonObject) throws Exception {
        String id = jsonObject.getString("id");
        if (StringUtils.isEmpty(id)) {
            return Result.error("运单信息获取错误");
        }

        HyDriver driver = userUtil.getDriver();
        //辽宁航信税务平台，司机装货时必须满足司机实名制
//        if (HyCfgUtil.isUsed2("liaoning_tax_report")) {
//            Result rDriverAuth = this.shippingNoteApiAlct56Service.queryDriverForAuth(driver);
//            //如果返回-3，会返回微信认证链接，需要司机去认证
//            if (-3 == rDriverAuth.getCode()) {
//                return Result.error(-3, rDriverAuth.getMessage());
//            }
//        }


        String strgoodsWeightLoading = jsonObject.getString("goodsWeightLoading");
        String imgLoading = jsonObject.getString("imgLoading");
        String loadingSceneImg = jsonObject.getString("loadingSceneImg");

        if (StringUtils.isEmpty(strgoodsWeightLoading)) {
            return Result.error("请填写装载量");
        }
        if ("1".equals(settingService.getSettingValueByTag2("usedLoadingImg"))) {
            if (StringUtils.isEmpty(imgLoading)) {
                return Result.error("请上传装货磅单照片");
            }
        }
        BigDecimal goodsWeightLoading = null;
        try {
            goodsWeightLoading = new BigDecimal(strgoodsWeightLoading);
        } catch (Exception e) {
            return Result.error("装货量格式错误");
        }
        HyShippingNote shippingNote = hyShippingNoteService.getByIdForUpdate(id);
        if (shippingNote == null) {
            return Result.error("运单信息不存在");
        }
        if (!"1".equals(shippingNote.getShippingStatus())) {

            if ("3".equals(shippingNote.getShippingStatus())) {
                return Result.error("该运单已经是装货状态");
            }

            return Result.error("运单状态信息错误");
        }

        if (!StringUtils.equals(driver.getId(), shippingNote.getDriverId())) {
            return Result.error("运单信息错误");
        }

        String payType = shippingNote.getPayType();
        //计算预付运费
        if ("3".equals(payType)) {
            String preType = shippingNote.getPreType();
            if ("1".equals(preType)) {
                //1按吨
                if (goodsWeightLoading != null) {
                    BigDecimal preFee = shippingNote.getPreUnitFee().multiply(goodsWeightLoading);
                    shippingNote.setPreFee(preFee);
                }
            } else {
                //整车
                shippingNote.setPreFee(shippingNote.getPreUnitFee());
            }
            shippingNote.setPrePayStatus("1");//预付待审核
        }

        shippingNote.setShippingStatus(ShippingStatus.运输中.getValue());//设置状态为运输中
        shippingNote.setStatusDtLoading(new Date());//实际装货完成时间
        shippingNote.setGoodsWeightLoading(goodsWeightLoading);

        hyShippingNoteService.getWatermarkPic(shippingNote, imgLoading, StringUtils.EMPTY,
                StringUtils.EMPTY, StringUtils.EMPTY
        );

//        HyOrder order = orderService.getById(shippingNote.getOrderId());
//        if (order == null) {
//            return Result.error("请选择所属货源");
//        }
        HyVehicle vehicle = vehicleService.getById(shippingNote.getVehicleId());
        //根据分公司配置判断是否上传装货现场照片
        HyCompanyConfig companyConfig = hyCompanyConfigService.getByCompanyId(shippingNote.getCompanyId());
        if (companyConfig != null && 1 == companyConfig.getScenePhoto()) {
            if (StringUtils.isEmpty(loadingSceneImg)) {
                return Result.error("装货现场照片不能为空");
            }
        }

        if (null == vehicle.getVehicleTonnage()) {
            return Result.error("当前车辆核定载质量不正确，请先维护车辆信息");
        }
        //记录货物质量超过车辆核定载质量
        if (shippingNote.getGoodsWeightLoading().compareTo(vehicle.getVehicleTonnage()) > 0) {
            HyShippingNoteViolation shippingNoteViolation = new HyShippingNoteViolation();
            shippingNoteViolation.setShippingNoteId(shippingNote.getId());
            shippingNoteViolation.setShippingNoteNumber(shippingNote.getShippingNoteNumber());
            shippingNoteViolation.setDriverId(shippingNote.getDriverId());
            shippingNoteViolation.setVehicleId(shippingNote.getVehicleId());
            shippingNoteViolation.setViolationType("1");
            shippingNoteViolation.setViolationTime(new Date());
            shippingNoteViolationService.save(shippingNoteViolation);
        }

        //万金油
        String izUsedGas = shippingNote.getIzUsedGas();
        if ("1".equals(izUsedGas) || "3".equals(izUsedGas)) {
            HyShippingNoteGas gas = hyShippingNoteGasService.getByShippingId(shippingNote.getId());
            if (gas == null) {
                gas = new HyShippingNoteGas();
                gas.setShippingId(shippingNote.getId());
                gas.setShippingNoteNumber(shippingNote.getShippingNoteNumber());
                gas.setGasStatus("1");
                gas.setIzUsedGas(izUsedGas);
                gas.setDriverId(shippingNote.getDriverId());
                gas.setDriverName(driver.getDriverName());
                gas.setGasRechargeAmount(shippingNote.getGasRechargeAmount());
                gas.setVehicleNumber(vehicle.getVehicleNumber());
                gas.setVehicleEnergyType(vehicle.getVehicleEnergyType());
                hyShippingNoteGasService.save(gas);
            }
            gasService.rechargeMsg(gas);

        }

        String waterMarkImg = hyShippingNoteService.buildWaterMarkImg(shippingNote, loadingSceneImg, "send");
        shippingNote.setLoadingSceneImg(
                StringUtils.isNotEmpty(waterMarkImg) ? waterMarkImg : loadingSceneImg
        );
//        loadingSceneImg=loadingSceneImg.replaceAll("\\\\","/");
//        shippingNote.setLoadingSceneImg( loadingSceneImg );


        //查询是否使用易云章
        String contractTemplate = hySettingService.getSettingValueByTag2("contract_template");
        if (contractTemplate.equals("1")) {
            HyConfig config = HyConfigUtils.getConfig();
            if (config == null) {
                return Result.error("未读取到配置信息");
            }

            if (!config.getYyzContractIzUse()) {
                return Result.error("未开启易云章配置");
            }
            HyCompany hyCompany = hyCompanyService.getById(shippingNote.getCompanyId());
            EclouModel eclouModel = new EclouModel();
            eclouModel.setHyDriverId(driver.getId());
            eclouModel.setHyEnterpriseId(hyCompany.getId());
            eclouModel.setVehicleId(vehicle.getId());
            eclouModel.setShippingNoteId(shippingNote.getId());
            //签署易云章合同节点-订阅消息
//            publisherRedisMessageService.publisherRedisMessage(RedisChannelEnum.ECLOUD_SDK,eclouModel);
            GenMqUtil.sendMsg(EnumGenHandler.YYZ_HANDLER, "", eclouModel);
        }
        if (contractTemplate.equals("0")) {

            if (StringUtils.isEmpty(shippingNote.getShippingContract())) {
                //如果司机签名图片不等于空直接使用之前司机签名图片签字
                if (driver.getDriverAutograph() != null) {
                    HyOrder order = orderService.getById(shippingNote.getOrderId());
                    if (order == null) {
                        return Result.error("货源信息错误");
                    }
                    JSONObject joOrder = dictUtil.parseObjectDict(order);
                    if (null != order.getSendDate()) {
                        joOrder.put("sendDate", DateUtils.dateTimeToString(order.getSendDate()));
                    }
                    if (null != order.getReceiveDate()) {
                        joOrder.put("receiveDate", DateUtils.dateTimeToString(order.getReceiveDate()));
                    }

                    String contractNum = CodeUtil.createContractNum();
                    joOrder.put("contractNum", contractNum);
                    Result result = generatePDF.pdfUtil(joOrder, shippingNote, driver);
                    if (result.isSuccess()) {
                        shippingNote.setShippingContract(result.getResult().toString());
                        shippingNote.setContractNum(contractNum);
                        shippingNote.setContractNum2(contractNum);
                        shippingNote.setContractType("承运人电子合同");
                        shippingNote.setContractStatus("1");
                        shippingNote.setContractOr("0");
                    }
                } else {
                    return Result.error(-1, "请签字!");
                }
            }
        }

        //鄂尔多斯监管判断超载及上报
        if (HyCfgUtil.isUsed2("ordos_report")) {
            HyCompanyConfig hyCompanyConfig = this.companyConfigService.getByCompanyId(shippingNote.getCompanyId());
            //200是鄂尔多斯市监管平台，写死的
            if (hyCompanyConfig.getParkReportPlatformType().intValue() == 200) {
                if (shippingNote.getGoodsWeightLoading().compareTo(vehicle.getVehicleTonnage()) > 0) {
                    return Result.error("市监管上报失败: 存在超载行为，请确认货物重量");
                }

                if (StrUtil.isEmpty(jsonObject.getString("lng")) || StrUtil.isEmpty(jsonObject.getString("lat"))) {
                    return Result.error("市监管上报失败: 定位失败，请确认是否开启手机定位权限");
                }

                IReportService reportService = ReportServiceFactory.getReport(ReportPlatformEnum.REPORT_PLATFORM_ORDOS.getCode());
                log.info("开始上报鄂尔多斯装货数据，{}", reportService.getReportType().getMsg());
                reportService.reportShippingNote(shippingNote, ShippingStatus.运输中.getValue(), jsonObject.getString("lng"), jsonObject.getString("lat"));
            }
        }

        String remark = jsonObject.getString("remark");//备注
        if (StringUtils.isNotEmpty(remark)){
            shippingNote.setRemark(remark);
        }

        hyShippingNoteService.updateById(shippingNote);

        //Modified start at 2024-07-15 for 重构运输节点消息通知功能
        this.applicationEventPublisher.publishEvent(ShippingNoticeEvent.builder()
                .msgType(MessageTypeEnum.MESSAGE_TYPE_LOAD.getCode())
                .shippingId(shippingNote.getId())
                .shippingNoteNumber(shippingNote.getShippingNoteNumber())
                .driverId(shippingNote.getDriverId())
                .vehicleId(shippingNote.getVehicleId())
                .dateTime(new Date())
                .loginUser(UserUtil.getLoginUser())
                .build());
//        //装货运输节点-订阅消息
//        if ("1".equals(shippingNote.getTosIdentification())) {
//            GenMqUtil.sendMsg(EnumGenHandler.SHIPPING_ENTRUCKING, "", shippingNote);
//        }
//        //大屏发送websocket消息
//        GenMqUtil.sendMsg(EnumGenHandler.DAPING, "", shippingNote);
        //Modified end at 2024-07-15 for 重构装货运输节点-订阅消息功能

        return Result.OK(shippingNote);
    }


    @AutoLog(value = "运单表-运单卸货")
    @ApiOperation(value = "运单表-运单卸货", notes = "运单表-运单卸货")
    @PostMapping(value = "/unloading")
    @Transactional
    public Result<?> unloading(@RequestBody JSONObject jsonObject) throws Exception {
        String id = jsonObject.getString("id");
        if (StringUtils.isEmpty(id)) {
            return Result.error("运单信息获取错误");
        }

        HyDriver driver = userUtil.getDriver();
        //辽宁航信税务平台，司机装货时必须满足司机实名制
//        if (HyCfgUtil.isUsed2("liaoning_tax_report")) {
//            Result rDriverAuth = this.shippingNoteApiAlct56Service.queryDriverForAuth(driver);
//            //如果返回-3，会返回微信认证链接，需要司机去认证
//            if (-3 == rDriverAuth.getCode()) {
//                return Result.error(-3, rDriverAuth.getMessage());
//            }
//        }

        String strgoodsWeightUnloading = jsonObject.getString("goodsWeightUnloading");
        String imgUnloading = jsonObject.getString("imgUnloading");
        String unloadingSceneImg = jsonObject.getString("unloadingSceneImg");
        String paymentCertificateImg = jsonObject.getString("paymentCertificateImg");

        if (StringUtils.isEmpty(strgoodsWeightUnloading)) {
            return Result.error("请填写卸货量");
        }
        if ("1".equals(settingService.getSettingValueByTag2("usedUnLoadingImg"))) {
            if (StringUtils.isEmpty(imgUnloading)) {
                return Result.error("请上传卸货磅单照片");
            }
        }
        if ("1".equals(settingService.getSettingValueByTag2("paymentCertificateSwitch"))) {
            if (StringUtils.isEmpty(paymentCertificateImg)) {
                return Result.error("请上传完税证明照片");
            }
        }
        BigDecimal goodsWeightUnloading = null;
        try {
            goodsWeightUnloading = new BigDecimal(strgoodsWeightUnloading);
        } catch (Exception e) {
            return Result.error("卸货量格式错误");
        }
        HyShippingNote shippingNote = hyShippingNoteService.getByIdForUpdate(id);

        if (StringUtils.isNotEmpty(paymentCertificateImg)) {
            shippingNote.setPaymentCertificateImg(paymentCertificateImg);
        }

        if (shippingNote == null) {
            return Result.error("运单信息不存在");
        }

        if (!"3".equals(shippingNote.getShippingStatus())) {

            if ("4".equals(shippingNote.getShippingStatus())) {
                return Result.error("该运单已经是卸货状态");
            }

            return Result.error("运单状态信息错误");
        }

        if (!StringUtils.equals(driver.getId(), shippingNote.getDriverId())) {
            return Result.error("运单信息错误");
        }
//        Integer second = DateUtils.getDifferentDaysByMillisecond(shippingNote.getStatusDtLoading(), new Date());
//        if (second <= 60 * 60) {
//            return Result.error("发货和收货时间逻辑有误（订单时间过短）！");
//        }

        //根据分公司配置判断是否上传卸货现场照片
        HyCompanyConfig companyConfig = hyCompanyConfigService.getByCompanyId(shippingNote.getCompanyId());
        if (companyConfig != null && 1 == companyConfig.getScenePhoto()) {
            if (StringUtils.isEmpty(unloadingSceneImg)) {
                return Result.error("卸货现场照片不能为空");
            }
        }


        String waterMarkImg = hyShippingNoteService.buildWaterMarkImg(shippingNote, unloadingSceneImg, "receive");
        shippingNote.setUnloadingSceneImg(
                StringUtils.isNotEmpty(waterMarkImg) ? waterMarkImg : unloadingSceneImg
        );

//        shippingNote.setUnloadingSceneImg(unloadingSceneImg);


        shippingNote.setGoodsWeightUnloading(goodsWeightUnloading);

        hyShippingNoteService.getWatermarkPic(shippingNote, StringUtils.EMPTY, imgUnloading,
                StringUtils.EMPTY, StringUtils.EMPTY
        );

        shippingNote.setStatusDtUnloading(new Date());//实际卸货完成时间

        //鄂尔多斯监管判断超载及上报
        if (HyCfgUtil.isUsed2("ordos_report")) {
            HyCompanyConfig hyCompanyConfig = this.companyConfigService.getByCompanyId(shippingNote.getCompanyId());
            //200是鄂尔多斯市监管平台，写死的
            if (hyCompanyConfig.getParkReportPlatformType().intValue() == 200) {
                HyVehicle vehicle = this.vehicleService.getById(shippingNote.getVehicleId());
                if (shippingNote.getGoodsWeightUnloading().compareTo(vehicle.getVehicleTonnage()) > 0) {
                    return Result.error("市监管上报失败: 存在超载行为，请确认货物重量");
                }

                if (StrUtil.isEmpty(jsonObject.getString("lng")) || StrUtil.isEmpty(jsonObject.getString("lat"))) {
                    return Result.error("市监管上报失败: 定位失败，请确认是否开启手机定位权限");
                }

                IReportService reportService = ReportServiceFactory.getReport(ReportPlatformEnum.REPORT_PLATFORM_ORDOS.getCode());
                log.info("开始上报鄂尔多斯卸货数据，{}", reportService.getReportType().getMsg());
                reportService.reportShippingNote(shippingNote, ShippingStatus.已交货.getValue(), jsonObject.getString("lng"), jsonObject.getString("lat"));
            }
        }

        //是否自动签收
        HyCustomerConfig hyCustomerConfig = customerConfigService.getByCustomerId(shippingNote.getCustomerId());
        if (hyCustomerConfig != null && "1".equals(hyCustomerConfig.getIzAutoSign())) {
            //核算
            hyShippingNoteService.calcCoss(shippingNote);
            //自动签收
            shippingNote.setShippingStatus(ShippingStatus.已签收.getValue());//设置状态为已交货
            shippingNote.setStatusDtSign(new Date());//货源完结时间

            //业务审核是否开启
            if (HyCfgUtil.isUsed("isOpenYewu")) {
                shippingNote.setShippingPayStatus("9"); //业务审核
            } else {
                shippingNote.setShippingPayStatus("1"); //申请对账
                shippingNote.setPayDtSubmitCheck(new Date());//申请对账时间
            }


            String realName = UserUtil.getLoginUser().getRName();
            shippingNote.setQsr(realName);//设置签收人

            hyShippingNoteService.updateById(shippingNote);
            //签收订阅消息
            if ("1".equals(shippingNote.getTosIdentification())) {
                GenMqUtil.sendMsg(EnumGenHandler.SHIPPING_DISCHARGE, "TosApi", shippingNote);
            }
        } else {
            shippingNote.setShippingStatus(ShippingStatus.已交货.getValue());//设置状态为已交货

            //        unloadingSceneImg=unloadingSceneImg.replaceAll("\\\\","/");
            //        shippingNote.setUnloadingSceneImg(unloadingSceneImg );
            hyShippingNoteService.updateById(shippingNote);
        }

        //Modified start at 2024-07-15 for 重构运输节点消息通知功能
        this.applicationEventPublisher.publishEvent(ShippingNoticeEvent.builder()
                .msgType(MessageTypeEnum.MESSAGE_TYPE_UNLOAD.getCode())
                .shippingId(shippingNote.getId())
                .shippingNoteNumber(shippingNote.getShippingNoteNumber())
                .driverId(shippingNote.getDriverId())
                .vehicleId(shippingNote.getVehicleId())
                .loginUser(userUtil.getLoginUser())
                .dateTime(new Date())
                .build());
        //Modified end at 2024-07-15 for 重构运输节点消息通知功能

        //大屏发送websocket消息
        //GenMqUtil.sendMsg(EnumGenHandler.DAPING, "", shippingNote);
        return Result.OK(shippingNote);
    }

    @AutoLog(value = "运单表-运单编辑")
    @ApiOperation(value = "运单表-运单编辑", notes = "运单表-运单编辑")
    @PostMapping(value = "/edit")
    public Result<?> edit(@RequestBody JSONObject jsonObject) throws Exception {
        HyDriver driver = userUtil.getDriver();
        String id = jsonObject.getString("id");
        if (StringUtils.isEmpty(id)) {
            return Result.error("运单信息获取错误");
        }

        String strgoodsWeightLoading = jsonObject.getString("goodsWeightLoading");
        String imgLoading = jsonObject.getString("imgLoading");
        String loadingSceneImg = jsonObject.getString("loadingSceneImg");

        String strgoodsWeightUnloading = jsonObject.getString("goodsWeightUnloading");
        String imgUnloading = jsonObject.getString("imgUnloading");
        String unloadingSceneImg = jsonObject.getString("unloadingSceneImg");

        String paymentCertificateImg = jsonObject.getString("paymentCertificateImg");



        if ("1".equals(settingService.getSettingValueByTag2("paymentCertificateSwitch"))) {
            if (StringUtils.isEmpty(paymentCertificateImg)) {
                return Result.error("请上传完税证明照片");
            }
        }

//        if (StringUtils.isEmpty(strgoodsWeightLoading)) {
//            return Result.error("请填写装载量");
//        }
//
//        if (StringUtils.isEmpty(strgoodsWeightUnloading)) {
//            return Result.error("请填写卸货量");
//        }
//
//
//        if ("1".equals(settingService.getSettingValueByTag2("usedLoadingImg"))) {
//            if (StringUtils.isEmpty(imgLoading)) {
//                return Result.error("请上传装货磅单照片");
//            }
//        }
//        if ("1".equals(settingService.getSettingValueByTag2("usedUnLoadingImg"))) {
//            if (StringUtils.isEmpty(imgUnloading)) {
//                return Result.error("请上传卸货磅单照片");
//            }
//        }


        HyShippingNote shippingNote = hyShippingNoteService.getById(id);

        if (StringUtils.isNotEmpty(paymentCertificateImg)) {
            shippingNote.setPaymentCertificateImg(paymentCertificateImg);
        }

        if (shippingNote == null) {
            return Result.error("运单信息不存在");
        }

        if (!StringUtils.equals(driver.getId(), shippingNote.getDriverId())) {
            return Result.error("运单信息错误");
        }

        String shippingPayStatus = shippingNote.getShippingPayStatus();
        if (!"0".equals(shippingPayStatus) && !"1".equals(shippingPayStatus)) {
            return Result.error("运单已对账,不能修改");
        }

        String remark = jsonObject.getString("remark");//备注
        if (StringUtils.isNotEmpty(remark)){
            shippingNote.setRemark(remark);
        }

        if (StringUtils.isNotEmpty(strgoodsWeightLoading)) {
            try {
                BigDecimal goodsWeightLoading = null;
                goodsWeightLoading = new BigDecimal(strgoodsWeightLoading);
                shippingNote.setGoodsWeightLoading(goodsWeightLoading);
            } catch (Exception e) {
                return Result.error("装货量格式错误");
            }
        }

        if (StringUtils.isNotEmpty(strgoodsWeightUnloading)) {
            try {
                BigDecimal goodsWeightUnloading = null;
                goodsWeightUnloading = new BigDecimal(strgoodsWeightUnloading);
                shippingNote.setGoodsWeightUnloading(goodsWeightUnloading);
            } catch (Exception e) {
                return Result.error("卸货量格式错误");
            }
        }


        //根据分公司配置判断是否上传卸货现场照片
        HyCompanyConfig companyConfig = hyCompanyConfigService.getByCompanyId(shippingNote.getCompanyId());
        if (companyConfig != null && 1 == companyConfig.getScenePhoto()) {
            if (StringUtils.isNotEmpty(loadingSceneImg)) {
                //是否修改装卸货现场图片 ，如修改重新添加水印。
                if (!StringUtils.equals(loadingSceneImg, shippingNote.getLoadingSceneImg())) {
                    String waterMarkImg = hyShippingNoteService.buildWaterMarkImg(shippingNote, loadingSceneImg, "send");
                    shippingNote.setLoadingSceneImg(StringUtils.isNotEmpty(waterMarkImg) ? waterMarkImg : loadingSceneImg);
                }
            }
            if (StringUtils.isNotEmpty(unloadingSceneImg)) {
                if (!StringUtils.equals(unloadingSceneImg, shippingNote.getUnloadingSceneImg())) {
                    String waterMarkImg = hyShippingNoteService.buildWaterMarkImg(shippingNote, unloadingSceneImg, "receive");
                    shippingNote.setUnloadingSceneImg(StringUtils.isNotEmpty(waterMarkImg) ? waterMarkImg : unloadingSceneImg);
                }
            }
        }
        //装卸货榜单加水印
        hyShippingNoteService.getWatermarkPic(shippingNote, imgLoading, imgUnloading,
                shippingNote.getImgLoading(), shippingNote.getImgUnloading()
        );

        hyShippingNoteService.updateById(shippingNote);
        return Result.OK(shippingNote);
    }

    @AutoLog(value = "运单表-撤销")
    @ApiOperation(value = "运单表-撤销", notes = "运单表-撤销")
    @PutMapping(value = "/chexiao")
    @Transactional
    public Result<?> chexiao(@RequestParam(name = "id", required = true) String id,
                             @RequestParam(name = "cancelReason", required = false, defaultValue = "") String cancelReason) {
        HyDriver driver = userUtil.getDriver();
        HyShippingNote hyShippingNote = hyShippingNoteService.getByIdForUpdate(id);
        if (hyShippingNote == null) {
            return Result.error("该运单不存在");
        }
        if (!"1".equals(hyShippingNote.getShippingStatus())) {
            return Result.error("不能撤销!");
        }

        if (!StringUtils.equals(hyShippingNote.getDriverId(), driver.getId())) {
            return Result.error("数据不存在!");
        }

        hyShippingNote.setCancelReason(cancelReason);
        hyShippingNote.setShippingStatus(ShippingStatus.已作废.getValue());
        //hyShippingNote.setPayDtSubmitAut(new Date());//申请审核时间
        hyShippingNoteService.updateById(hyShippingNote);

        //取消运单订阅消息
 //       if ("1".equals(hyShippingNote.getAlctIdentification())) {
            //GenMqUtil.sendMsg(EnumGenHandler.SHIPPING_CANCEL, "", hyShippingNote);
            //publisherRedisMessageService.publisherRedisMessage(RedisChannelEnum.SHIPPING_CANCEL, hyShippingNote);
 //       }
        String izUsedGas = hyShippingNote.getIzUsedGas();
        if ("1".equals(izUsedGas) || "3".equals(izUsedGas)) {
            //万金油回收油气
            gasService.backMsg(hyShippingNote);
        }

        return Result.OK("撤销成功!");
    }


    @AutoLog(value = "部平台上传定位信息")
    @ApiOperation(value = "部平台上传定位信息", notes = "部平台上传定位信息")
    @PostMapping(value = "/dingwei")
    public Result<?> appLocation(@RequestBody JSONObject reqObject, HttpServletRequest req) throws Exception {

        HyConfig config = HyConfigUtils.getConfig();
        if (null == config) {
            return Result.error("配置信息错误");
        }

        String id = reqObject.getString("id");
        if (StringUtils.isEmpty(id)) {
            return Result.error("运单id不能为空");
        }
        if (StringUtils.isEmpty(reqObject.getString("jingdu"))) {
            return Result.error("经度位置信息错误");
        }
        if (StringUtils.isEmpty(reqObject.getString("weidu"))) {
            return Result.error("维度位置信息错误");
        }
        if (StringUtils.isEmpty(reqObject.getString("type"))) {
            return Result.error("起始类型错误");
        }

        HyShippingNote shippingNote = hyShippingNoteService.getById(id);
        if (shippingNote == null) {
            return Result.error("运单信息不存在");
        }
        //获取分公司id
        HyCompanyConfig companyConfig = hyCompanyConfigService.getByCompanyId(shippingNote.getCompanyId());
        if (companyConfig == null) {
            return Result.error("公司信息不存在");
        }

        Integer reportPlatformType = companyConfig.getReportPlatformType();
        String reportPlatformName = ReportPlatformEnum.getMsg(reportPlatformType.intValue());
        log.info("发送部平台公司监管平台配置:{} - {} - {} - {}", reqObject.toJSONString(),
                companyConfig.getCompanyId(), reportPlatformType, reportPlatformName);

        try {
            IReportService reportService = ReportServiceFactory.getReport(companyConfig.getReportPlatformType());
            reportService.checkReport();
        } catch (Exception e) {
            log.error("发送部平台公司监管平台未开启: {} - {}", companyConfig.getCompanyId(), reportPlatformName);
            return Result.error("监管平台未开启");
        }

        this.applicationEventPublisher.publishEvent(
                AppLocationEvent.builder()
                    .shippingId(id)
                    .longitude(reqObject.getString("jingdu"))
                    .latitude(reqObject.getString("weidu"))
                    .type(reqObject.getString("type"))
                    .remark(reqObject.getString("remark"))
                    .address(reqObject.getString("address"))
                    .areaCode(reqObject.getString("areaCode"))
                    .hyShippingNote(shippingNote)
                    .reportPlatformType(companyConfig.getReportPlatformType())
                    .build()
        );

        return Result.OK();
    }


//    @AutoLog(value = "部平台上传定位信息")
//    @ApiOperation(value = "部平台上传定位信息", notes = "部平台上传定位信息")
//    @PostMapping(value = "/dingwei")
//    public Result<?> dingwei(@RequestBody JSONObject jsonObject, HttpServletRequest req) throws Exception {
//
//        HyConfig config = HyConfigUtils.getConfig();
//        if (config == null) {
//            return Result.error("配置信息错误");
//        }
//
//        String id = jsonObject.getString("id");
//        if (StringUtils.isEmpty(id)) {
//            return Result.error("运单id不能为空");
//        }
//        if (StringUtils.isEmpty(jsonObject.getString("jingdu"))) {
//            return Result.error("经度位置信息错误");
//        }
//        if (StringUtils.isEmpty(jsonObject.getString("weidu"))) {
//            return Result.error("维度位置信息错误");
//        }
//        if (StringUtils.isEmpty(jsonObject.getString("type"))) {
//            return Result.error("起始类型错误");
//        }
//
//        HyShippingNote shippingNote = hyShippingNoteService.getById(id);
//        if (shippingNote == null) {
//            return Result.error("运单信息不存在");
//        }
//        //获取分公司id
//        HyCompanyConfig companyConfig = hyCompanyConfigService.getByCompanyId(shippingNote.getCompanyId());
//        if (companyConfig == null) {
//            return Result.error("公司信息不存在");
//        }
//        //上报类型1-河北,2-天津
//        Integer reportPlatformType = companyConfig.getReportPlatformType();
//        InitReturnBean init = null;
//        String reportPlatformName = null;
//        if (1 == reportPlatformType) {
//            if (!config.getWzHbIzUse()) {
//                return Result.error("河北app配置未开启");
//            }
//            reportPlatformName = "河北";
//            init = HyConfigUtils.getInitReturnBean();
//        } else if (2 == reportPlatformType) {
//            if (!config.getWzTjIzUse()) {
//                return Result.error("天津app配置未开启");
//            }
//            reportPlatformName = "天津";
//            init = HyConfigUtils.getTjinitReturnBean();
//        } else if (3 == reportPlatformType) {
//            if (!config.getWzAhIzUse()) {
//                return Result.error("安徽app配置未开启");
//            }
//            reportPlatformName = "安徽";
//            init = HyConfigUtils.getAhinitReturnBean();
//        } else if (4 == reportPlatformType) {
//            if (!config.getWzJsIzUse()) {
//                return Result.error("江苏app配置未开启");
//            }
//            reportPlatformName = "江苏";
//            init = HyConfigUtils.getJsinitReturnBean();
//        } else if (5 == reportPlatformType) {
//            if (!config.getWzSxIzUse()) {
//                return Result.error("山西app配置未开启");
//            }
//            reportPlatformName = "山西";
//            init = HyConfigUtils.getSxinitReturnBean();
//        } else if (6 == reportPlatformType) {
//            if (!config.getWzSdIzUse()) {
//                return Result.error("山东app配置未开启");
//            }
//            reportPlatformName = "山东";
//            init = HyConfigUtils.getSdinitReturnBean();
//        } else if (7 == reportPlatformType) {
//            if (!config.getWzHbIzUse()) {
//                return Result.error("湖北app配置未开启");
//            }
//            reportPlatformName = "湖北";
//            init = HyConfigUtils.getInitReturnBean();
//        } else {
//            if (!config.getWzHbIzUse()) {
//                return Result.error("其他app配置未开启");
//            }
//            reportPlatformName = "其他";
//            init = HyConfigUtils.getInitReturnBean();
//        }
//
//        if (init == null) {
//            return Result.error("上报类型错误,不能上报位置信息");
//        }
//        if (!init.isResult()) {
//            System.out.println(reportPlatformName + "交通部sdk2.0初始化失败,不能上报位置信息");
//            return Result.error(reportPlatformName + "交通部sdk2.0初始化失败,不能上报位置信息");
//        }
//        DingWeiModel model = new DingWeiModel();
//        model.setId(jsonObject.getString("id"));
//        model.setJingdu(jsonObject.getString("jingdu"));
//        model.setWeidu(jsonObject.getString("weidu"));
//        model.setType(jsonObject.getString("type"));
//        model.setReportPlatformType(reportPlatformType);
//        model.setHyShippingNote(shippingNote);
//        //部平台上传定位信息 节点-订阅消息
////        publisherRedisMessageService.publisherRedisMessage(RedisChannelEnum.DINGWEI_SDK,model);
//        GenMqUtil.sendMsg(EnumGenHandler.DINGWEI_SDK, "", model);
//
//        return Result.OK();
//    }


    @AutoLog(value = "公开货源抢单")
    @ApiOperation(value = "公开货源抢单", notes = "公开货源抢单")
    @PostMapping(value = "/qd")
    public Result<?> qd(@RequestBody JSONObject jsonObject) {
        HyDriver driver = userUtil.getDriver();
        int shippingNoteTotal = hyDriverService.getCurrentShippingNoteCount(driver.getId());
        if (shippingNoteTotal >= 1) {
            return Result.error("当前有没完成的运单,不能抢单");
        }

        vehicleService.getVehicleByDriverId(driver.getId());



        String driver_is_examine = hySettingService.getSettingValueByTag2("driver_is_examine");
        //0关闭 1打开
        if ("1".equals(driver_is_examine)) {
            if ("3".equals(driver.getExamineStatus())) {
                return Result.error("因证件信息错误未审核通过，暂不能接单，请及时更正");
            }
        }


        String orderId = jsonObject.getString("orderId");
        if (StringUtils.isEmpty(orderId)) {
            return Result.error("未找到货源信息");
        }

        HyOrder order = orderService.getById(orderId);
        if (order == null) {
            return Result.error("未找到货源信息");
        }
        //检查货源信息
        if ("8".equals(order.getOrderStatus())) {
            return Result.error("该货源已完结");
        }
        if (!"2".equals(order.getOrderStatus())) {
            return Result.error("该货源未发布");
        }
        if (!"2".equals(order.getOrderType())) {
            return Result.error("该货源不是公开货源");
        }
        if (!"1".equals(order.getOrderType2())) {
            return Result.error("该货源不是抢单货源");
        }
        String prefix = "qd:" + order.getId() + "::";
        String key = prefix + driver.getId();
        if (redisUtil.hasKey(key)) {
            long expireTime = redisUtil.getExpire(key);
            return Result.error(-11, "当前货源您已抢过单, " + expireTime + " 秒后才能继续抢单");
        }

//        String orderkey = "qd:" + orderId;
//        if(!redisUtil.hasKey(orderkey)){
//            //更新数量
//        }

        if (ObjectUtil.isNotEmpty(order.getVehicleNum())) {
            int vehicleNum = order.getVehicleNum().intValue();
            //检查缓存是否能抢单
            Set<String> keys = redisUtil.keys(prefix + "*");
            if (keys.size() >= vehicleNum) {
                return Result.error("该货源已经抢完,不能继续抢单");
            }

            //检查数据库是否能抢单
            int shippingNums = orderService.getShippingNums(orderId);
            if (shippingNums >= vehicleNum) {
                return Result.error("该货源已经抢完,不能继续抢单");
            }
        }

        //添加抢单缓存记录
        boolean ret = redisUtil.set(key, driver.getId(), 10 * 60);
        if (ret) {
            return Result.OK("抢单成功,有效时间为10分钟,请在有效期内完成接单");
        }
        return Result.error("抢单失败,请重新尝试!");
    }


    @ApiOperation(value = "司机竞价分页列表查询", notes = "司机竞价分页列表查询")
    @GetMapping(value = "/pricelist")
    public Result<?> queryOrderPriceList(HyOrderPriceVO hyOrderPriceVO,
                                         @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                         @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
        HyDriver driver = userUtil.getDriver();
        QueryWrapper<HyOrderPrice> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("hy_order_price.driver_id", driver.getId());

        if (StringUtils.isNotEmpty(hyOrderPriceVO.getKeyword())) {
            queryWrapper.and(
                    qw -> qw.like("hy_order.send_address_name", hyOrderPriceVO.getKeyword())
                            .or().like("hy_order.receive_address_name", hyOrderPriceVO.getKeyword())
            );
        }
        queryWrapper.eq("hy_order.del_flag", "0");
        queryWrapper.orderByDesc("hy_order_price.create_time");
        Page<HyOrderPriceVO> page = new Page<HyOrderPriceVO>(pageNo, pageSize);
        IPage<HyOrderPriceVO> pageList = hyOrderPriceService.getPageList(page, queryWrapper);
        return Result.OK(pageList);
    }


    @AutoLog(value = "公开货源竞价")
    @ApiOperation(value = "公开货源竞价", notes = "公开货源竞价")
    @PostMapping(value = "/bidding")
    public Result<?> bidding(@RequestBody HyOrderPrice hyOrderPrice) {
        String orderId = hyOrderPrice.getOrderId();
        if (StringUtils.isEmpty(orderId)) {
            return Result.error("未找到货源信息");
        }
        BigDecimal price = hyOrderPrice.getPrice();
        if (price == null) {
            return Result.error("价格不能未空");
        }
        HyDriver driver = userUtil.getDriver();
//        HyShippingNote currentShippingNote = hyDriverService.getCurrentShippingNote(driver.getId());
        int shippingNoteTotal = hyDriverService.getCurrentShippingNoteCount(driver.getId());
        if (shippingNoteTotal >= 1) {
            return Result.error("当前有没完成的运单,不能抢单");
        }
        HyOrder order = orderService.getById(orderId);
        if (order == null) {
            return Result.error("未找到货源信息");
        }
        //检查货源信息
        if ("8".equals(order.getOrderStatus())) {
            return Result.error("该货源已完结");
        }
        if (!"2".equals(order.getOrderStatus())) {
            return Result.error("该货源未发布");
        }
        if (!"2".equals(order.getOrderType())) {
            return Result.error("该货源不是公开货源");
        }
        if (!"2".equals(order.getOrderType2())) {
            return Result.error("该货源不是竞价货源");
        }
        //检查是否竞价过改货源
        HyOrderPrice dt = hyOrderPriceService.getByDriverAndOrderId(driver.getId(), orderId);
        if (dt != null) {
            return Result.error("已经竞价过了,不能重复竞价");
        }
        hyOrderPrice.setDriverId(driver.getId());
        hyOrderPrice.setOrderId(orderId);
        hyOrderPrice.setCustomerId(order.getCustomerId());
        hyOrderPrice.setPriceSt("0");
        hyOrderPriceService.save(hyOrderPrice);
        return Result.OK("竞价成功");
    }


    @ApiOperation(value = "司机指派货源列表", notes = "司机指派货源列表")
    @GetMapping(value = "/driverOrderList")
    public Result<?> queryOrderDriverList(HyOrderDriverVO hyOrderDriverVO,
                                          @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
        HyDriver driver = userUtil.getDriver();
        QueryWrapper<HyOrderDriverVO> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("hy_order_driver.driver_id", driver.getId());
        queryWrapper.eq("order_status", "2");

        if (StringUtils.isNotEmpty(hyOrderDriverVO.getKeyword())) {
            queryWrapper.and(
                    qw -> qw.like("hy_order.send_address_name", hyOrderDriverVO.getKeyword())
                            .or().like("hy_order.receive_address_name", hyOrderDriverVO.getKeyword())
            );
        }

        queryWrapper.eq("hy_order.del_flag", "0");
        queryWrapper.orderByDesc("hy_order_driver.create_time");
        Page<HyOrderDriverVO> page = new Page<HyOrderDriverVO>(pageNo, pageSize);
        IPage<HyOrderDriverVO> pageList = hyOrderDriverService.getPageList(page, queryWrapper);
        return Result.OK(pageList);
    }
}
